package com.example.chapter3.pojo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

//有时候我们也可以使用注解＠ConfigurationProperties ， 通过它使得配置上
//有所减少,这里在注解＠ConfigurationProperties 中配置的字符串 database，将与 POJO 的属性名称组成属性
//的全限定名去配置文件里查找 ，这样就能将对应的属性读入到 POJO 当中
@Component
@ConfigurationProperties("database")
public class DataBaseProperties {
//    @Value("${database.driverName}")
    private String driverName = null;

//    @Value("${database.url}")
    private String url = null;

    private String username = null;

    private String password = null;

    public String getDriverName() {
        return driverName;
    }

    public void setDriverName(String driverName) {
        System.out.println(driverName);
        this.driverName = driverName;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        System.out.println(url);
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

//    @Value("${database.username}")
    public void setUsername(String username) {
        System.out.println(username);
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

//    @Value("${database.password}")
    public void setPassword(String password) {
        System.out.println(password);
        this.password = password;
    }
}
